package com.it;

import java.io.*;

public class 序列化测试 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        String str = "2312";
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
        objectOutputStream.writeObject(str);
        byte[] bytes = byteArrayOutputStream.toByteArray();

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
        ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
        String s = (String) objectInputStream.readObject();
        System.out.println("s = " + s);
//            objectInputStream.
    }
}
